package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DwScore;
import com.ruoyi.system.service.IDwScoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 点赞关注收藏Controller
 * 
 * @author ruoyi
 * @date 2024-01-19
 */
@RestController
@RequestMapping("/system/score")
public class DwScoreController extends BaseController
{
    @Autowired
    private IDwScoreService dwScoreService;

    /**
     * 查询点赞关注收藏列表
     */
    @PreAuthorize("@ss.hasPermi('system:score:list')")
    @GetMapping("/list")
    public TableDataInfo list(DwScore dwScore)
    {
        startPage();
        List<DwScore> list = dwScoreService.selectDwScoreList(dwScore);
        return getDataTable(list);
    }

    /**
     * 导出点赞关注收藏列表
     */
    @PreAuthorize("@ss.hasPermi('system:score:export')")
    @Log(title = "点赞关注收藏", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DwScore dwScore)
    {
        List<DwScore> list = dwScoreService.selectDwScoreList(dwScore);
        ExcelUtil<DwScore> util = new ExcelUtil<DwScore>(DwScore.class);
        util.exportExcel(response, list, "点赞关注收藏数据");
    }

    /**
     * 获取点赞关注收藏详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:score:query')")
    @GetMapping(value = "/{scoreId}")
    public AjaxResult getInfo(@PathVariable("scoreId") Long scoreId)
    {
        return AjaxResult.success(dwScoreService.selectDwScoreByScoreId(scoreId));
    }

    /**
     * 新增点赞关注收藏
     */
    @PreAuthorize("@ss.hasPermi('system:score:add')")
    @Log(title = "点赞关注收藏", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DwScore dwScore)
    {
        return toAjax(dwScoreService.insertDwScore(dwScore));
    }

    /**
     * 修改点赞关注收藏
     */
    @PreAuthorize("@ss.hasPermi('system:score:edit')")
    @Log(title = "点赞关注收藏", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DwScore dwScore)
    {
        return toAjax(dwScoreService.updateDwScore(dwScore));
    }

    /**
     * 删除点赞关注收藏
     */
    @PreAuthorize("@ss.hasPermi('system:score:remove')")
    @Log(title = "点赞关注收藏", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scoreIds}")
    public AjaxResult remove(@PathVariable Long[] scoreIds)
    {
        return toAjax(dwScoreService.deleteDwScoreByScoreIds(scoreIds));
    }
}
